package com.bmps.springcloud.insuredmicroservice.service.underwrite.strategy.riskamount;

import com.bmps.springcloud.insuredmicroservice.constant.accept.AcceptConstant;
import com.bmps.springcloud.insuredmicroservice.model.accept.medium.PolicyRiskInfoModel;
import com.bmps.springcloud.insuredmicroservice.repository.underwrite.coresystem.InsuranceRiskAmountRepository;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * description:
 * LLT008风险保额策略
 * 风险保额：保额*费率
 * 费率：按被保人投保年龄、保险期限取值
 *
 * @author jackdaw
 * @date 2020-04-16 17:28
 */
@Component
public class Llt008Strategy implements InsuranceRiskAmountStrategy {
    private final InsuranceRiskAmountRepository insuranceRiskAmountRepository;

    public Llt008Strategy( InsuranceRiskAmountRepository insuranceRiskAmountRepository) {
        this.insuranceRiskAmountRepository = insuranceRiskAmountRepository;
    }

    @Override
    public BigDecimal getRiskAmount(PolicyRiskInfoModel policyRiskInfoModel, boolean isCurrent, Object object) {
        //查询数据库
        BigDecimal bigDecimal = insuranceRiskAmountRepository.getRiskAmountRateLlt008(policyRiskInfoModel.getInsureYear(), policyRiskInfoModel.getInsuredAppAge());
        return bigDecimal == null ? BigDecimal.valueOf(-1) : policyRiskInfoModel.getAmnt().multiply(bigDecimal);
    }
}
